package com.example.mapper;

import Video.Dto.VideoType;
import Video.Dto.Video;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface VideoMapper {
    @Select("select * from videos where id=#{id}")
    Video getVideoById(@Param("id") int id);

    @Select("select * from videos")
    List<Video> getVideos();

    @Select("select * from videos where type=#{type}")
    List<Video> getVideosByType(@Param("type") int type);

    @Select("select sort from video_types where type = #{type}")
    String getTypeName(int type);

    @Insert("insert into videos (type,video,name) values(#{type},#{video},#{name})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    boolean insertVideo(Video video);

//    @Update("update videos " +
//            "set type = #{type}, " +
//            "video = #{video}, " +
//            "name = #{name}")
//    int updateVideo(Video video);

    @Delete("delete from videos where id=#{id}")
    void deleteVideos(int id);

    @Select("select sort from video_types")
    List<String> getTypes();

    @Select("select * from video_types")
    List<VideoType> getTypesAll();

    @Select("select sort from video_types")
    List<String> getTypesjol();

    @Insert("insert into video_types(sort) values (#{sort})")
    void addTypes(String sort);

    @Delete("delete from video_types where type=#{id}")
    void deleteTypes(int id);


//    @Update("update video_types " +
//            "set sort = #{sort}")
//    void updateTypes(VideoType type);
}
